<?php require_once(dirname(__FILE__) . '/inc/config.inc.php');
IsModelPriv('goodsorder');
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$tbname = '#@__user';
if ($id > 0) {
    $user_arr = $dosql->GetOne("select * from $tbname where id='$id'");
    if (is_array($user_arr) && isset($user_arr['id'])) {
        $user = $user_arr;
    } else {
        exit("id不存在");
    }
} else {
    exit("非法请求");
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>renl</title>
    <link href="templates/style/admin.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="templates/js/jquery.min.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->

    <link href="layui/css/layui.css" rel="stylesheet" type="text/css" media="all"/>
    <script src="layui/layui.all.js"></script>
</head>
<body>


<style>
    .layui-upload-list img { max-width: 200px; height: auto;}

    .layui-form-label {
        float: left;
        display: block;
        padding: 9px;
        width: 90px;
        font-weight: 400;
        line-height: 20px;
        text-align: right;
    }

    .layui-input-block {
        margin-left: 80px;
        min-height: 36px;
    }
</style>
<div class="layui-form " lay-filter="layuiadmin-form-tags" id="layuiadmin-app-form-tags">
    <div class="layui-form-item mt10">
        <label class="layui-form-label">id</label>
        <div class="layui-input-inline" style="height: 38px; line-height: 38px; color: darkred">
            <?php echo $user['id'] ?>
            <input type="hidden" name="id" id="id" value=" <?php echo $user['id'] ?>"/>


            昵称：<?php echo $user['nickname'] ?>
        </div>

    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">头像</label>
        <div class="layui-input-block">
            <div class="layui-upload">
                <img src="<?php echo $user['headimgurl'] ?>" width="100">


            </div>
        </div>

        <div class="layui-form-item mt10">
            <label class="layui-form-label">工程师</label>
            <div class="layui-input-block" style="height: 38px; line-height: 38px; color: darkred">
                <?php echo $user['school']."  ".$user['truename']."  ".$user['mobile'] ?>

            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">操作<span class="red">*</span></label>
            <div class="layui-input-block">
                <input name="moshi" type="radio" value="add" title="奖励" lay-filter="moshi"  checked=""/>
                <input name="moshi" type="radio" value="move" title="扣除" lay-filter="moshi"/>


            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">事项<span class="red">*</span></label>
            <div class="layui-input-inline">
                <select name="feetype" id="feetype" class="form-control" lay-filter="feetype">
                    <option value="0">请选择</option>
                    <?php
                    $dosql->Execute("SELECT * FROM `#@__cascadedata` WHERE `datagroup`='feetype' and fee='add' order by orderid ASC", 10);
                    while ($row = $dosql->GetArray(10)) {
                        echo '<option value="' . $row['datavalue'] . '" >' . $row['dataname'] . '</option>';

                    }
                    ?>
                </select>

            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">分值<span class="red">*</span></label>
            <div class="layui-input-inline">

                <input type="text" name="fee" value="" lay-verify="required"
                       placeholder="请输入..." autocomplete="off" class="layui-input" style="width: 80px;display: inline-block"> 正整数

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注<span class="red">*</span></label>
            <div class="layui-input-block">
                <textarea id="remark" name="remark" class="layui-textarea"></textarea>

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-inline">
                <input type="button" lay-submit lay-filter="layuiadmin-app-tags-submit" value="确认" class="layui-btn">
            </div>
        </div>

    </div>
    <script>
        layui.use(['form', 'laydate', 'table', 'layedit', 'upload'], function () {
            var $ = layui.$,
                admin = layui.admin,
                element = layui.element,
                layer = layui.layer,
                view = layui.view,
                table = layui.table,
                laytpl = layui.laytpl,
                laydate = layui.laydate,
                layedit = layui.layedit,
                upload = layui.upload,
                form = layui.form;


            $(function () {
                $("input[name = 'op']").change(function () {
                    var opop=$(this).val();
                    $.ajax({
                        type: 'post',
                        url: "getFeeType.php?op=" + opop,
                        //data: {areaId:areaId},
                        dataType: 'json',
                        success: function (res) {
                            console.log(res.data);
                            $("#feetype").html("");
                            $("#feetype").html(res.data);
                        }

                    });

                });
            });

            form.on('radio(moshi)', function(data){
                console.log(data);
                var opop=data.value;
                $.ajax({
                    type: 'post',
                    url: "getFeeType.php?op=" + opop,
                    //data: {areaId:areaId},
                    dataType: 'json',
                    success: function (res) {
                        console.log(res.data);
                        $("#feetype").html("");
                        $("#feetype").html(res.data);
                        layui.form.render();
                    }

                });
            });

            layui.form.render();

            form.render(null, 'layuiadmin-form-tags');
            //监听提交
            form.on('submit(layuiadmin-app-tags-submit)', function (data) {
                var field = data.field; //获取提交的字段


                var feetype = field.feetype;
                if (feetype == 0) {
                    layer.msg("请选择积分操作的事由");
                    return false;
                }
                

                //提交 Ajax 成功后，关闭当前弹层并重载表格
                $.ajax({
                    url: "json/fee/fee_do.php",
                    data: {
                        "field": field,
                        "action": 'add'
                    },
                    type: "POST",
                    dataType: "json",
                    success: function (res) {
                        console.log(res);
                        if (res.code == 0) {
                            console.log("返回成功");
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                        }

                    }
                });
            });

        });
    </script>
</body>
</html>